package com.ls.admin.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ls.admin.service.FinanceService;
import com.ls.admin.pojo.CompanyRecon;
import com.ls.admin.pojo.InternalRecon;
import com.ls.admin.pojo.Recharge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/finance")
@CrossOrigin
public class FinanceController {

    @Autowired
    private FinanceService financeService;


    //查看用户购买接口套餐的消费记录
    @GetMapping("/checkCompanyRecon")
    public List<CompanyRecon> checkCompanyRecon(){
        return financeService.checkCompanyRecon();
    }

    //查看指定用户购买接口套餐的消费记录
    @GetMapping("/findByCompanyRecon")
    public List<CompanyRecon> findByCompanyRecon(@RequestParam String appid){
        return financeService.findByCompanyReconid(appid);
    }

    //查看用户购买接口套餐的总消费额
    @GetMapping("/totalCompanyRecon")
    public Double totalCompanyRecon(){
        Double total=financeService.totalCompanyRecon();
        return total;
    }

    //查看指定用户购买接口套餐的总消费额
    @GetMapping("/findByTotalCompanyRecon")
    public Double findByTotalCompanyRecon(@RequestParam String appid){
        Double total = financeService.findByTotalCompanyRecon(appid);
        return total;
    }


    //查看调用第三方接口的消费记录
    @GetMapping("/checkInternal")
    public List<InternalRecon> checkInternal(){
        return financeService.checkInternal();
    }

    //查看指定用户调用第三方接口的消费记录
    @GetMapping("/findByInternal")
    public List<InternalRecon> findByInternal(@RequestParam Integer customerid){
        return financeService.findByInternal(customerid);
    }

    //查看调用第三方接口的总消费
    @GetMapping("/totalInternal")
    public Double totalInternal(){
        Double total=financeService.totalInternal();
        return total;
    }

    //查看指定用户调用第三方接口的总消费
    @GetMapping("/findByTotalInternal")
    public Double findByTotalInternal(@RequestParam Integer customerid){
        Double total=financeService.findByTotalInternal(customerid);
        return total;
    }


    //查看用户充值记录
    @GetMapping("/checkRecharge")
    public List<Recharge> checkRecharge(){
        return financeService.checkRecharge();
    }

    //查看指定用户充值记录
    @GetMapping("/findByRecharge")
    public List<Recharge> findByRecharge(@RequestParam String appid){
        return financeService.findByRecharge(appid);
    }

    //用户充值总额
    @GetMapping("/totalRecharge")
    public Double totalRecharge(){
        Double total=financeService.totalRecharge();
        return total;
    }

    //指定用户充值金额
    @GetMapping("/findByTotalRecharge")
    public Double findByTotalRecharge(@RequestParam String appid){
        Double total=financeService.findByTotalRecharge(appid);
        return total;
    }


}
